/**
 * created: $date$
 * from: $from$
 */
package $pack$;

import java.util.Collection;
import java.util.Map;

import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.directory.SearchResult;

import speculoos.core.Mapper;
import speculoos.core.MapperException;
import speculoos.utils.TypeHelper;
import $bean.beanDescriptor.beanClass.name$;

/**
 * This class handles mapping an Attributes object to 
 * an instance of $simpleName$.
 *
 * @author abailly
 */
public class AttributesTo$simpleName$ implements Mapper {

	/*
	 * (non-Javadoc)
	 * 
	 * @see speculoos.core.Mapper#map(java.lang.Object, java.util.Map)
	 */
	public Object map(Object input, Map param) throws MapperException {
		try {
			TypeHelper th = TypeHelper.instance; /* for converting values */
			Attributes attrs = (Attributes)input;
			Attribute attribute = null;
			$simpleName$ res = new $simpleName$();
        	$primitives:{$if(map.(it.name))$$templates/mappers/propertysetPrim(prop=it,mapto=map.(it.name))$$\n$$endif$}$
        	$scalars:{$if(map.(it.name))$$templates/mappers/propertysetScalar(prop=it,mapto=map.(it.name))$$\n$$endif$}$
        	$containers:{$if(map.(it.name))$$templates/mappers/propertysetContainers(prop=it,mapto=map.(it.name))$$\n$$endif$}$
			return res;
		} catch (NamingException ex) {
			throw new MapperException(getName() + ": JNDI error ", ex);
		}
	}


	public String getName() {
		return "AttributesTo$simpleName$";
	}

}
